#pragma once
#include <tuple>
#include "IImageData.h"

namespace ja2{ namespace sgp
{
	//! Indexed image data.
	class ImageDataIndexed : public IImageData
	{
		// Typedefs
	public:
		//! Image data type.
		typedef std::unique_ptr<char[]> DataType_t;
		//! Palette type.
		typedef std::unique_ptr<char[]> PaletteType_t;
	private:
		//! Pair <data, Rect>.
		typedef std::tuple<DataType_t, Rect> DataPair_t;

		// Attributes
	private:
		//! Vector of sub-images.
		std::vector<DataPair_t> m_SubImages;
		//! Palette. Always has 255  * 3 (RGB) entries.
		PaletteVector_t const m_Palette;
		
		// Operations
	public:
		//! See base.
		virtual void blit_transparent(IDirectDrawSurfacePtr &pSurface, Rect const &SourceRect) const;
		//! See base.
		virtual void blit_shadow(IDirectDrawSurfacePtr &pSurface, Rect const &SourceRect) const;
		//! See base.
		virtual PaletteVector_t const *palette() const;
		//! Add sub-image.
		void add_sub_image(DataType_t &&pData, Rect const &SourceRect);

		// Construction/Destruction
	public:
		ImageDataIndexed(std::uint16_t Size, PaletteVector_t &&Palette);
	};
} /*sgp*/} /*ja2*/
